var t = getApp();

Page({
    data: {
        title: "",
        type: 1,
        finished: !1,
        loading: !1,
        page: 1,
        expendList: [],
        fundList: []
    },
    onLoad: function(t) {
        this.setData({
            type: t.type
        });
    },
    onShow: function() {
        1 == this.data.type ? (wx.setNavigationBarTitle({
            title: "支出记录"
        }), this.getExpendData()) : (wx.setNavigationBarTitle({
            title: "公益明细"
        }), this.getFundData());
    },
    getExpendData: function() {
        var a = this, e = t.getNetAddresss("plugin.public-fund.frontend.controllers.fund.expendList");
        wx.showLoading({
            title: "loading"
        }), this.setData({
            loading: !0
        }), t._getNetWork({
            url: e,
            data: {
                page: this.data.page
            },
            success: function(t) {
                if (1 === t.data.result) {
                    var e = t.data.data.list;
                    (e.current_page >= e.last_page || e.data.length < e.per_page) && a.setData({
                        finished: !0
                    }), a.setData({
                        page: ++a.data.page,
                        expendList: a.data.page > 1 ? a.data.expendList.concat(e.data) : e.data
                    });
                } else wx.showToast({
                    title: t.data.msg
                });
            },
            complete: function() {
                wx.hideLoading(), a.setData({
                    loading: !1
                });
            }
        });
    },
    getFundData: function() {
        var a = this, e = t.getNetAddresss("plugin.public-fund.frontend.controllers.fund.amountList");
        wx.showLoading({
            title: "loading"
        }), this.setData({
            loading: !0
        }), t._getNetWork({
            url: e,
            data: {
                page: this.data.page
            },
            success: function(t) {
                if (1 === t.data.result) {
                    var e = t.data.data.list;
                    (e.current_page >= e.last_page || e.data.length < e.per_page) && a.setData({
                        finished: !0
                    }), a.setData({
                        page: ++a.data.page,
                        fundList: a.data.page > 1 ? a.data.fundList.concat(e.data) : e.data
                    });
                } else wx.showToast({
                    title: t.data.msg
                });
            },
            complete: function() {
                wx.hideLoading(), a.setData({
                    loading: !1
                });
            }
        });
    },
    onReachBottom: function() {
        if (this.data.finished || this.data.loading) return !1;
        1 == this.data.type ? this.getExpendData() : this.getFundData();
    },
    onShareAppMessage: function() {}
});